package com.eight.cloud.auth.common.security.provider;

import com.eight.cloud.auth.common.security.authentication.VerificationCodeAuthenticationToken;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.SpringSecurityMessageSource;

/**
 * @ClassName: VerificationCodeAuthenticationProvider
 * @Author: TXC
 * @Date: 2024-10-15 15:50
 **/
public class VerificationCodeAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware {
    protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        return new VerificationCodeAuthenticationToken("", "");
    }

    @Override
    public boolean supports(Class<?> authentication) {
        return VerificationCodeAuthenticationToken.class.isAssignableFrom(authentication);
    }

    @Override
    public void afterPropertiesSet() throws Exception {

    }

    @Override
    public void setMessageSource(MessageSource messageSource) {
        this.messages = new MessageSourceAccessor(messageSource);
    }
}
